home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 424_02 / ED-157 / scroll_up.c < prev    next >
C/C++ Source or Header  |  1993-09-10  |  2KB  |  57 lines

  1. /*
  2.  * Copyright (C) 1992 by Rush Record (rhr@clio.rice.edu)
  3.  * 
  4.  * This file is part of ED.
  5.  * 
  6.  * ED is free software; you can redistribute it and/or modify it under the terms
  7.  * of the GNU General Public License as published by the Free Software Foundation.
  8.  * 
  9.  * ED is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  10.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11.  * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  12.  * 
  13.  * You should have received a copy of the GNU General Public License along with ED
  14.  * (see the file COPYING).  If not, write to the Free Software Foundation, 675
  15.  * Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17. #include "opsys.h"
  18.  
  19. #include "rec.h"
  20. #include "window.h"
  21. #include "ed_dec.h"
  22.  
  23. /******************************************************************************\
  24. |Routine: scroll_up
  25. |Callby: bigger_win change_case fix_display insert_win remove_win
  26. |Purpose: Scrolls the current window up if possible. Returns the number
  27. |         of lines actually scrolled.
  28. |Arguments:
  29. |    nscroll is the number of lines to try to scroll.
  30. \******************************************************************************/
  31. Int scroll_up(nscroll)
  32. register Int nscroll;
  33. {
  34.     register Int i;
  35.     register rec_ptr r;
  36.  
  37.     for(r = BOTREC,i = nscroll;r != BASE && r != 0 && i > 0;i--,r = r->next)
  38.     {
  39.         TOPREC = TOPREC->next;
  40.         if(BOTREC != 0 && BOTREC != BASE)
  41.             BOTREC = BOTREC->next;
  42.     }
  43.     if((i = nscroll - i) > 0)    /* actual number scrollable */
  44.     {
  45.         if(i > BOTROW - TOPROW)
  46.             ref_window(CURWINDOW);
  47.         else
  48.         {
  49.             move(TOPROW,1);
  50.             del_line(i);
  51.             paint(BOTROW - i + 1,BOTROW,FIRSTCOL);
  52.         }
  53.     }
  54.     return(i);
  55. }
  56.  
  57.